import com.alibaba.fastjson.JSON;
import news.newstopic.entity.NewsTopic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author Gong
 * @Description
 * @dATE 2022/2/28 15:55
 **/
public class Test
{
    public static void main(String[] args) {
//        Map obj = new HashMap();
//        obj.put("k1","v1");
//        obj.put("k2","v1");
        List<NewsTopic> newsTopicList =new ArrayList<>();
        NewsTopic obj = new NewsTopic();
        obj.setId(1);
        obj.setTopicName("国内");
        newsTopicList.add(obj);
        newsTopicList.add(obj);
        //将JSON对象转化为字符串
        String objStr = JSON.toJSONString(newsTopicList);
        System.out.println(objStr);
    }
}
